<template>
	<div class="docker">
		<div
			v-for="(item, index) of dockerList"
			:key="item.text"
			class="docker__item"
			:class="{'docker__item--active': index === currentIndex}"
		>
			<router-link :to="item.link">
				<div class="iconfont" v-html="item.icon"></div>
				<div class="docker__title">{{item.text}}</div>
			</router-link>
		</div>
	</div>
</template>

<script>
	import { defineComponent } from 'vue'

	export default defineComponent({
		name: 'Tab',
		props: ['currentIndex'],
		setup() {
			const dockerList = [
				{ icon: '&#xe6f3;', text: '首页', link: { name: 'Home' } },
				{ icon: '&#xe7e5;', text: '购物车', link: { name: 'Cart' } },
				{ icon: '&#xe61e;', text: '订单', link: { name: 'OrderList' } },
				{ icon: '&#xe660;', text: '我的', link: { name: 'Me' } }
			]
			return {
				dockerList
			}
		}
	})
</script>

<style lang="scss" scoped>
	@import '../style/variable.scss';

	.docker {
		display: flex;
		position: absolute;
		left: 0;
		bottom: 0;
		width: 100%;
		height: .49rem;
		padding: 0 .18rem;
		box-sizing: border-box;
		border-top: .01rem solid $content-background;
		color: $content-font-color;
		&__item {
			flex: 1;
			text-align: center;
			a {
				color: $content-font-color;
				text-decoration: none;
			}
			&--active {
				a {
					color: #1fa4fc;
					text-decoration: none;
				}
			}
			.iconfont {
				margin: .07rem 0 .02rem 0;
				font-size: .18rem;
			}
			&__title {
				font-size: .2rem;
				transform: scale(.5, .5);
				transform-origin: center top;
			}
		}
	}
</style>
